package us.icitap.cm.business.entities;


import java.io.Serializable;
import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import org.eclipse.persistence.annotations.Customizer;

import us.icitap.cm.utils.MyCustomizer;

@Entity
@Customizer(MyCustomizer.class)
@Table(name="UNIQUE_NUMBER",schema="MPC")
public class UniqueNumber implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 8258479657384002796L;

	@Transient
	private boolean unGenerated = true;
	
	@Id
	@Column(name="UNIQUE_NUMBER", length=12)
	private String uniqueNumber;
	
	@Column
	private String description;
	
	@ManyToOne
	@JoinColumn(name="REQUESTING_OFFICER_ID")
	private Officer requestingOfficer;
	
	@ManyToOne
	@JoinColumn(name="ORG_STRUCTURE_ID")
	private OrgStructure orgStructure;
	
	@OneToOne(mappedBy="uniqueNumber")
	private EventReport eventReport;
	
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name="RECORD_DATE")
	private Date recordDate;
	
	private boolean active;
	
	@Column(name="RECORD_USER")
	private String recordUser;
	
	@Column(name="DEACTIVATE_USER")
	private String deactivateUser;
	
	@Column(name="REASON_FOR_DEACTIVATION")
	private String reasonForDeactivation;


	
	public String getUniqueNumber() {
		return uniqueNumber;
	}

	public void setUniqueNumber(String uniqueNumber) {
		this.uniqueNumber = uniqueNumber;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Officer getRequestingOfficer() {
		return requestingOfficer;
	}

	public void setRequestingOfficer(Officer requestingOfficer) {
		this.requestingOfficer = requestingOfficer;
	}

	public OrgStructure getOrgStructure() {
		return orgStructure;
	}

	public void setOrgStructure(OrgStructure orgStructure) {
		this.orgStructure = orgStructure;
	}

	public Date getRecordDate() {
		return recordDate;
	}

	public void setRecordDate(Date recordDate) {
		this.recordDate = recordDate;
	}

	public boolean isActive() {
		return active;
	}

	public void setActive(boolean active) {
		this.active = active;
	}

	public String getRecordUser() {
		return recordUser;
	}

	public void setRecordUser(String recordUser) {
		this.recordUser = recordUser;
	}

	public String getDeactivateUser() {
		return deactivateUser;
	}

	public void setDeactivateUser(String deactivateUser) {
		this.deactivateUser = deactivateUser;
	}

	public String getReasonForDeactivation() {
		return reasonForDeactivation;
	}

	public void setReasonForDeactivation(String reasonForDeactivation) {
		this.reasonForDeactivation = reasonForDeactivation;
	}

	public EventReport getEventReport() {
		return eventReport;
	}

	public void setEventReport(EventReport eventReport) {
		this.eventReport = eventReport;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((uniqueNumber == null) ? 0 : uniqueNumber.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		UniqueNumber other = (UniqueNumber) obj;
		if (uniqueNumber == null) {
			if (other.uniqueNumber != null)
				return false;
		} else if (!uniqueNumber.equals(other.uniqueNumber))
			return false;
		return true;
	}

	public boolean isUnGenerated() {
		return unGenerated;
	}

	public void setUnGenerated(boolean unGenerated) {
		this.unGenerated = unGenerated;
	}
	
}